package com.tube.fiddles.mvc.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tube.fiddles.domain.Menu;
import com.tube.fiddles.service.MenuService;

@Controller
@RequestMapping("/test")
public class TestController {
    
    @Autowired
    private MenuService menuService;

    @RequestMapping(value = "", method = RequestMethod.GET)
    @ResponseBody
    public String hello(@RequestParam String name) {
        
        Menu menu = new Menu();
        menu.setMenuName("Menu01");
        menu.setMenuUrl("http://www.baidu.com");
        menuService.save(menu);
        
        return "Hello " + name;
    }
}
